/**防止重复点击重复弹出message弹框 */
import { ElMessage } from 'element-plus'
//定义一个新的Message方法，多传入一个offset参数
const resetMessage:any = (options:any) => {
  return ElMessage({
    ...options,
    offset: 60,
  });
};

//重写一遍success的方法,将offset写入options
["success", "warning", "info", "error"].forEach((type:any) => {
    resetMessage[type] = (options:any) => {
    if (typeof options === "string") {
      options = {
        message: options,
        offset: 70,
        showClose:true,
        duration:2000
      };
    }
    options.type = type;
    return ElMessage(options);
  };
});
export const Message = resetMessage;